﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EIS_desktop
{
    public delegate void SheejaDelegate(object sender,EventArgs e);
    public partial class MonYear : UserControl
    {
       
        [Category("MyEvent")]
        public static event SheejaDelegate SheejaEvent;
        
        
        private string _month;
        private int _year;
        private short numericmonth;

        [Category("MonthYear")]
        [Description("Numeral of Selected Month")]
        public short NumericMonth
        {
            get { return numericmonth; }
        }

        [Category("MonthYear")]
        [Description("MyContolProperties")]
        public string Month
        {
            get { return _month; }
            set { _month = value; }
        }
        [Category("MonthYear")]
        [Description("MyContolProperties")]
        public int Year
        {
            get { return _year; }
            set { _year = value; }
        }

        public MonYear( )
        {
            InitializeComponent();
            
        }

        protected void OnSheejaDelegate(object sender, EventArgs e)
        {
            if (SheejaEvent != null)
            {
                SheejaEvent(this, e);
            }
        }
     
        private void monyear_Load(object sender, EventArgs e)
        {
            for (int year = 2000; year <= 2020; year++)
            {
                cmbYear.Items.Add(year);
            }
            cmbYear.SelectedIndexChanged += new EventHandler(cmbYear_SelectedIndexChanged);
        }

        void MonYear_MonYearSelected(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cmbYear.Text))
            {
                MessageBox.Show("Select year from the dropdown");
            }
            if (string.IsNullOrEmpty(Month))
            {
                MessageBox.Show("Select month");
            } 
        }
        void cmbYear_SelectedIndexChanged(object sender, EventArgs e)
        {
            Year = Convert.ToInt32(cmbYear.Text);
        }
        private void mybtnclick(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            Month = btn.Text;
            
        }
        
    }
    //public partial class MonYear : UserControl
    //{
    //    private  string _month;
    //    private int _year;
    //    private short numericmonth;

    //    [Category("MonthYear")]
    //    [Description("Numeral of Selected Month")]
    //    public short NumericMonth
    //    {
    //        get { return numericmonth; }
    //    }
        
    //    [Category("MonthYear")]
    //    [Description("MyContolProperties")]
    //    public string Month
    //    {
    //        get { return _month; }
    //        set { _month = value; }
    //    }
    //    [Category("MonthYear")]
    //    [Description("MyContolProperties")]
    //    public int Year
    //    {
    //        get { return _year; }
    //        set { _year = value; }
    //    }
    //    public MonYear()
    //    {
    //        InitializeComponent();
    //    }

    //    private void monyear_Load(object sender, EventArgs e)
    //    {
    //        for (int year = 2000; year <= 2020; year++)
    //        {
    //            cmbYear.Items.Add(year);
    //        }
    //        this.Shrink();
    //    }

    //    public delegate void MonthYearSelectHandler(object sender, EventArgs   e);
    //    [Category("MyEvent")]
    //    public event MonthYearSelectHandler MonthYearSelected;

    //    public void OnSelected(MonYearEventArgs e)
    //    {
    //        if (MonthYearSelected != null)
    //        {
    //            MonthYearSelected(this, e);
    //        }
    //    }
      
    //    private void Mon_Click(object sender, EventArgs e)
    //    {
    //       Button btnmon=(Button)sender;
    //       Month = btnmon.Text;

    //       switch (btnmon.Text.ToLower())
    //       {
    //           case "jan": numericmonth = 1;
    //               break;
    //           case "feb": numericmonth = 2;
    //               break;
    //           case "mar": numericmonth = 3;
    //               break;
    //           case "apr": numericmonth = 4;
    //               break;
    //           case "may": numericmonth = 5;
    //               break;
    //           case "jun": numericmonth = 6;
    //               break;
    //           case "jul": numericmonth = 7;
    //               break;
    //           case "aug": numericmonth = 8;
    //               break;
    //           case "sep": numericmonth = 9;
    //               break;
    //           case "oct": numericmonth = 10;
    //               break;
    //           case "nov": numericmonth = 11;
    //               break;
    //           case "dec": numericmonth = 12;
    //               break;
                   
    //       };
    //       try
    //       {
    //           this.Year = Convert.ToInt32(cmbYear.Text);
    //       }
    //       catch
    //       {
    //           MessageBox.Show("Select Year First");
    //       }

    //       lblMonYear.Text = this.Month + " " + this.Year.ToString();
    //    }

    //    private void monyear_Click(object sender, EventArgs e)
    //    {
    //        GrowBig();
    //    }

    //    private void monyear_Leave(object sender, EventArgs e)
    //    {
    //        this.Shrink();
    //    }
    //    private void Shrink()
    //    {
    //        this.Width = 20;
    //        this.Height = 20;
    //        this.BackColor = Color.CornflowerBlue;
    //    }
    //    private void GrowBig()
    //    {
    //        this.Width = 254;
    //        this.Height = 214;
    //    }
    //}
    //public partial class MonYearEventArgs : EventArgs
    //{
    //    public MonYearEventArgs(string mon, string year)
    //    {

    //    }
    //    public delegate void MonYearEventHandler(object sender, MonYearEventArgs e);
        
    //}

    
}
